<?php if (!defined('THINK_PATH')) exit(); /*a:6:{s:65:"D:\douzhi\PHP\ask\public/../application/home\view\index\info.html";i:1654763113;s:51:"D:\douzhi\PHP\ask\application\home\view\layout.html";i:1653012221;s:56:"D:\douzhi\PHP\ask\application\home\view\common\meta.html";i:1652757039;s:58:"D:\douzhi\PHP\ask\application\home\view\common\script.html";i:1652755224;s:58:"D:\douzhi\PHP\ask\application\home\view\common\header.html";i:1653118101;s:58:"D:\douzhi\PHP\ask\application\home\view\common\footer.html";i:1652754708;}*/ ?>
<!DOCTYPE html>
<html>
	<head>
		<!-- 引用样式 -->
		<meta charset="utf-8">
<title>ask论坛</title>
<link rel="stylesheet" href="/static/home/layui/css/layui.css">
<link rel="stylesheet" href="/static/home/css/global.css">
<link rel="stylesheet" href="/static/home/css/common.css">

		<!-- 引入js -->
		<script src="/static/home/layui/layui.js"></script>
<script>
layui.cache.page = '';
layui.cache.user = {
  username: '游客'
  ,uid: -1
  ,avatar: '/static/home/images/avatar/00.jpg'
  ,experience: 83
  ,sex: '男'
};
layui.config({
  version: "3.0.0"
  ,base: '/static/home/mods/' //这里实际使用时，建议改成绝对路径
}).extend({
  fly: 'index'
}).use('fly');
</script>
	</head>
	<body>
		<!-- 引用头部 -->
		<div class="fly-header layui-bg-black">
  <div class="layui-container">
    <a class="fly-logo" href="<?php echo url('home/index/index'); ?>">
      <img src="/static/home/images/logo.png" alt="layui">
    </a>
    
    <ul class="layui-nav fly-nav-user">
      
      <!-- 登入后的状态 -->
      <?php if(\think\Request::instance()->action() != 'login' && \think\Request::instance()->action() != 'register'): if(\think\Cookie::get('LoginUser')): ?>
			  <li class="layui-nav-item">
				<a class="fly-nav-avatar" href="javascript:;">
				  <cite class="layui-hide-xs"><?php echo $LoginUser['nickname']; ?></cite>
				  <?php if($LoginUser['auth'] == 1): ?>
				  <i class="iconfont icon-renzheng layui-hide-xs" title="认证信息：<?php echo $LoginUser['nickname']; ?>"></i>
				  <?php else: ?>
				  <span style="color: #c00;"> 未认证 </span>
				  <?php endif; ?>
				  <i class="layui-badge fly-badge-vip layui-hide-xs">VIP<?php echo $LoginUser['vip']; ?></i>
				  <img src="<?php echo $LoginUser['avatar_cdn']; ?>">
				</a>
				<dl class="layui-nav-child">
				  <dd><a href="<?php echo url('home/user/profile'); ?>"><i class="layui-icon">&#xe620;</i>基本设置</a></dd>
				  <dd><a href="user/message.html"><i class="iconfont icon-tongzhi" style="top: 4px;"></i>我的消息</a></dd>
				  <dd><a href="user/home.html"><i class="layui-icon" style="margin-left: 2px; font-size: 22px;">&#xe68e;</i>我的主页</a></dd>
				  <hr style="margin: 5px 0;">
				  <dd><a href="<?php echo url('home/index/loginout'); ?>" style="text-align: center;">退出</a></dd>
				</dl>
			  </li>
		 <?php else: ?>
			 <!-- 未登入的状态 -->
			 <li class="layui-nav-item">
			   <a class="iconfont icon-touxiang layui-hide-xs" href="user/login.html"></a>
			 </li>
			 <li class="layui-nav-item">
			   <a href="<?php echo url('home/index/login'); ?>">登入</a>
			 </li>
			 <li class="layui-nav-item">
			   <a href="<?php echo url('home/index/register'); ?>">注册</a>
			 </li>
			 <!-- <li class="layui-nav-item layui-hide-xs">
			   <a href="/app/qq/" onclick="layer.msg('正在通过QQ登入', {icon:16, shade: 0.1, time:0})" title="QQ登入" class="iconfont icon-qq"></a>
			 </li>
			 <li class="layui-nav-item layui-hide-xs">
			   <a href="/app/weibo/" onclick="layer.msg('正在通过微博登入', {icon:16, shade: 0.1, time:0})" title="微博登入" class="iconfont icon-weibo"></a>
			 </li> -->
		 <?php endif; endif; ?>
    </ul>
  </div>
</div>
		<!-- 引入内容部分 -->
		<!-- 引用编辑器 -->
<link rel="stylesheet" href="/static/kindeditor/themes/default/default.css" />
<script src="/static/kindeditor/kindeditor-all.js"></script>
<script src="/static/kindeditor/lang/zh-CN.js"></script>

<style type="text/css">
	.ke-container{
		width: 100% !important;
	}
</style>

<div class="layui-container">
    <div class="layui-row layui-col-space15">
      <div class="layui-col-md8 content detail">
        <div class="fly-panel detail-box">
          <h1><?php echo $post['title']; ?></h1>
          <div class="fly-detail-info">
            <!-- <span class="layui-badge">审核中</span> -->
            <span class="layui-badge layui-bg-green fly-detail-column"><?php echo $post['cate']['name']; ?></span>
            
            
            <?php if($post['accept'] > 0): ?>
                <span class="layui-badge" style="background-color: #5FB878;">已结</span>
            <?php else: ?>
                <span class="layui-badge" style="background-color: #999;">未结</span>
            <?php endif; if($post['state'] == 1): ?>
            <span class="layui-badge layui-bg-black">置顶</span>
            <?php elseif($post['state'] == 2): ?>
            <span class="layui-badge layui-bg-red">热门</span>
            <?php elseif($post['state'] == 3): ?>
            <span class="layui-badge layui-bg-orange">精华</span>
            <?php endif; ?>
            <div class="fly-admin-box" data-id="123">
                <?php if($post['userid'] == $userid): ?>
                    <span class="layui-btn layui-btn-xs jie-admin del" data-id="<?php echo $post['id']; ?>" type="del">删除</span>
                <?php endif; if($post['userid'] != $userid): if($collect == 1): ?>
                        <a href="#" class="layui-btn layui-btn-xs jie-admin layui-bg-red delshou" data-id="<?php echo $post['id']; ?>">取消收藏</a>
					<?php elseif($collect == 0): ?>
					    <span class="layui-btn layui-btn-xs jie-admin collection" data-id="<?php echo $post['id']; ?>">收藏</span>
					<?php endif; ?>
                    <!-- <span class="layui-btn layui-btn-xs jie-admin" type="set" field="stick" rank="0" style="background-color:#ccc;">取消置顶</span> -->
                <?php endif; ?>
              <!-- <span class="layui-btn layui-btn-xs jie-admin" type="set" field="status" rank="1">加精</span>  -->
              <!-- <span class="layui-btn layui-btn-xs jie-admin" type="set" field="status" rank="0" style="background-color:#ccc;">取消加精</span> -->
            </div>
            <span class="fly-list-nums"> 
              <a href="#comment"><i class="iconfont" title="回答">&#xe60c;</i> <?php echo $post['comment_count']; ?></a>
              <i class="iconfont" title="人气">&#xe60b;</i> <?php echo $VisitCount; ?>
            </span>
          </div>
          <div class="detail-about">
            <a class="fly-avatar" href="<?php echo url('home/user/index',['userid' => $post['userid']]); ?>">
              <img src="<?php echo $post['user']['avatar_cdn']; ?>" alt="贤心">
            </a>
            <div class="fly-detail-user">
              <a href="<?php echo url('home/user/index',['userid' => $post['userid']]); ?>" class="fly-link">
                <cite><?php echo $post['user']['nickname']; ?></cite>
                <i class="iconfont icon-renzheng" title="认证信息：<?php echo $post['user']['nickname']; ?>"></i>
                <i class="layui-badge fly-badge-vip">VIP <?php echo $post['user']['vip']; ?></i>
              </a>
              <span><?php echo $post['createtime']; ?></span>
            </div>
            <div class="detail-hits" id="LAY_jieAdmin" data-id="123">
              <span style="padding-right: 10px; color: #FF7200">悬赏：<?php echo $post['point']; ?>积分</span>
              <?php if($post['userid'] == $userid): ?>
                <span class="layui-btn layui-btn-xs jie-admin" type="edit"><a href="<?php echo url('home/post/edit',['postid' => $post['id']]); ?>">编辑此贴</a></span>
              <?php endif; ?>
            </div>
          </div>
          <div class="detail-body photos">
            <?php echo $post['content']; ?>
          </div>
        </div>
		
		<!-- 回复区域 -->
        <div class="fly-panel detail-box" id="flyReply">
          <fieldset class="layui-elem-field layui-field-title" style="text-align: center;">
            <legend>回帖</legend>
          </fieldset>
  
          <ul class="jieda" id="jieda">
			  
            <?php if($CommentList): ?>
             
                <?php echo CommentHtml($CommentList,$post,$LoginUser); else: ?>
                <!-- 无数据时 -->
                <li class="fly-none">消灭零回复</li>
            <?php endif; ?>
			
            <!-- 无数据时 -->
            <!-- <li class="fly-none">消灭零回复</li> -->
          </ul>
          
           <?php if($LoginUser && $post['accept'] == null): ?>
			  <div id="reply" style="font-size: 22px;margin-bottom: 5px;"></div>
			  <div class="layui-form layui-form-pane">
				<form action="<?php echo url('home/comment/add'); ?>" method="post">
				  <div class="layui-form-item layui-form-text">
					<a name="comment"></a>
					<div class="layui-input-block">
					  <textarea name="content" id="content" style="height: 300px;width:100%;"></textarea>
					  <!-- <textarea id="L_content" name="content" required lay-verify="required" placeholder="请输入内容"  class="layui-textarea fly-editor" style="height: 150px;"></textarea> -->
					</div>
				  </div>
				  <div class="layui-form-item">
					<input type="hidden" name="postid" value="<?php echo $post['id']; ?>">
					<input type="hidden" name="pid" value="0">
					<button class="layui-btn" lay-submit>提交回复</button>
				  </div>
				</form>
			  </div>
			<?php endif; ?>
        </div>
      </div>
      <div class="layui-col-md4">
		  
		  <div class="fly-panel fly-rank fly-rank-reply" id="LAY_replyRank">
		      <h3 class="fly-panel-title">回贴周榜</h3>
		      <dl>
		          <!--<i class="layui-icon fly-loading">&#xe63d;</i>-->
		  		<?php foreach($WeekList as $item): ?>
		          <dd>
		              <a href="user/home.html">
		                  <img
		                      src="<?php echo $item['user']['avatar']; ?>"><cite><?php echo $item['user']['nickname']; ?></cite><i><?php echo $item['userid']; ?>次回答</i>
		              </a>
		          </dd>
		          <?php endforeach; ?>
		      </dl>
		  </div>
  
          <!-- 无数据时 -->
          <!--
          <div class="fly-none">没有相关数据</div>
          -->
  
        <div class="fly-panel" style="padding: 20px 0; text-align: center;">
          <img src="/static/home/images/weixin.jpg" style="max-width: 100%;" alt="layui">
          <p style="position: relative; color: #666;">微信扫码关注 layui 公众号</p>
        </div>
  
      </div>
    </div>
  </div>
  <script type="text/javascript">
    var editor;
	KindEditor.ready(function(K) {
		editor = K.create('textarea[name="content"]');
	})
  	layui.use(['layer'],function(){
		var $ = layui.jquery,
		layer = layui.layer
		
		// 删除评论功能
		$('.delcom').click(function(){
			let comid = $(this).data('comid')
			console.log(comid)
			
			// 发起ajax请求
			$.ajax({
				type:'post',
				url:`<?php echo url('home/comment/delcom'); ?>`,
				data:{
					comid
				},
				dataType:'json',
				success:function(res){
					if(res.code === 1)
					{
						layer.msg(res.msg,{icon: 1},function(){
							 location.reload();
						})
					}else{
						layer.msg(res.msg,{icon: 5})
					}
				}
			})
		})
		
		// 回复
		$('.reply').click(function(){
		  let pid = $(this).data('pid')
	
		  $('input[name="pid"]').val(pid)
	
		  let nickname = $(this).data('nickname')
	
		  let reply = '回复@'+nickname
	
		  $('#reply').html(reply)
	
		  editor.focus()
	
		})
		
		// 点赞
		$('.jieda-zan').click(function(){
			// 评论id
			let comid = $(this).data('id')
			
			$.ajax({
				type:'post',
				url:`<?php echo url('home/comment/like'); ?>`,
				data:{
				  comid
				},
				dataType:'json',
				success:function(res)
				{
				  if(res.code === 1)
				  {
					layer.msg(res.msg,{icon: 1},function(){
						 location.reload();
					})
				  }else{
					layer.msg(res.msg,{icon: 5})
				  }
				}
			})
		})
		
		// 如果需要异步评论
		// $('#btn').click(function(){
		//   设置同步
		//   editor.sync()
	
		//   let content = $('#content').val()
		//   console.log(content)
	
		//   return false
		// })
		
		// 采纳
		$('.accept').click(function(){
		  /* 
			1、获取评论id => 传给后台
			2、帖子id => 获取评论id => 后台查询
		  */
	
		  let comid = $(this).data('comid')
	
		  $.ajax({
			type:'post',
			url:`<?php echo url('home/comment/accept'); ?>`,
			data:{
			  comid
			},
			dataType:'json',
			success:function(res)
			{
			  if(res.code === 1)
			  {
				layer.msg(res.msg,{icon: 1},function(){
				  location.reload();
				})
			  }else{
				layer.msg(res.msg,{icon: 5})
			  }
			}
		  })
	
		})
		
		// 删除帖子
		$('.del').click(function(){
			var postid = $(this).data('id')
			
			layer.confirm('确定删除帖子？',{icon:3,title:'提示'},function(index){
				
				// 发起请求
				$.ajax({
				  type:'post',
				  url:`<?php echo url('home/post/del'); ?>`,
				  data:{
					postid
				  },
				  dataType:'json',
				  success:function(res)
				  {
					if(res.code === 1)
					{
					  layer.msg('删除成功',{icon: 1},function(index){
						location.href = res.url
					  })
					}else{
					  layer.msg(res.msg,{icon: 5})
					}
				  }
				})
				
				layer.close(index)
			})
			
		})
		
		// 收藏帖子
		$('.collection').click(function(){
			var postid = $(this).data('id')
			
			layer.confirm('确定收藏帖子？',{icon:3},function(index){
				
				// 发起请求
				$.ajax({
				  type:'post',
				  url:`<?php echo url('home/post/collection'); ?>`,
				  data:{
					postid
				  },
				  dataType:'json',
				  success:function(res)
				  {
					if(res.code === 1)
					{
					  layer.msg('收藏成功',{icon: 1},function(index){
						location.href = res.url
					  })
					}else{
					  layer.msg(res.msg,{icon: 5},function(){
						location.href = res.url
					  })
					}
				  }
				})
				
				layer.close(index)
			})
		})
		
		// 个人主页取消收藏帖子
		$('.delshou').click(function(){
			var collectid = $(this).data('id')
			
			layer.confirm('确定取消收藏帖子？',{icon:3},function(index){
				
				// 发起请求
				$.ajax({
				  type:'post',
				  url:`<?php echo url('home/post/delcollect'); ?>`,
				  data:{
					collectid
				  },
				  dataType:'json',
				  success:function(res)
				  {
					if(res.code === 1)
					{
					  layer.msg('取消收藏成功',{icon: 1},function(index){
						location.href = res.url
					  })
					}else{
					  layer.msg(res.msg,{icon: 5},function(){
						location.href = res.url
					  })
					}
				  }
				})
				
				layer.close(index)
			})
		})
	})
  </script>
		<!-- 引用尾部 -->
		<div class="fly-footer">
  <p>2017 &copy; <a href="http://www.layui.com/" target="_blank">Fly技术社区</a></p>
</div>
	</body>
</html>
